/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ucmconfchecker.UI;

import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.swing.JComboBox;

/**
 *
 * @author Alex
 */
public class Utils {
    
    
    public static <T> T firstValue(Map<? extends Object,T> map){
        Iterator<T> iterator = map.values().iterator();
        if(iterator.hasNext()){
            return iterator.next();
        }
        return null;
    }
    public static <K> K firstKey(Map<K,? extends Object> map){
        Iterator<K> iterator = map.keySet().iterator();
        if(iterator.hasNext()){
            return iterator.next();
        }
        return null;
    }

    public static <T> void setItems(JComboBox combo, Collection<T> values) {
        combo.removeAllItems();
        if(values!=null){
            for(T value: values){
                combo.addItem(value);
            }
        }
    }
}
